import React, {Component, useRef, useState} from 'react';
import {PageContainer} from '@ant-design/pro-layout';
import {Table, Tag, Space, Button, Image, TreeSelect, Switch, message} from 'antd';
import {getGoodsLists, setGoodsPutAway} from "@/services/ant-design-pro/goods";
import {PlusOutlined} from "@ant-design/icons";
import {history} from "@@/core/history";
import ProTable, {ActionType, ProColumns, TableDropdown} from "@ant-design/pro-table";

const CombinedData = () =>{
const [search, setSearch] = useState({status: 1, include: 'productattrvalue'})
const actionRef = useRef<ActionType>();

const columns: ProColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
    search: false,
    align: 'center',
    width: 50,
  },
  {
    title: 'Key',
    dataIndex: 'product_name',
    search: false,
    align: 'center',
    width: 200,
  },
  {
    title: '数据组名称',
    dataIndex: 'productattrvalue["ot_price"]',
    search: false,
    align: 'center',
    width: 150,
  },
  {
    title: '库存',
    dataIndex: 'stock',
    search: false,
    align: 'center',
    width: 200,
  },
  {
    title: '数据搜索',
    dataIndex: 'search',
    search: true,
    hideInTable: true,
    defaultValue:'hls',
    renderFormItem: (_, {defaultRender}) => {
      return defaultRender(_);
    },
  },

  {
    title: '操作',
    valueType: 'option',
    align: 'center',
    render: (text, record, _, action) => [

      <a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
        数据列表
      </a>,
      <a
        key="editable"
        onClick={() => history.push('/manageGoods/editGoods/3433')}
      >
        编辑
      </a>,
      <a
        key="editable"
        onClick={() => history.push('/manageGoods/editGoods/3433')}
      >
        删除
      </a>,
      // <TableDropdown
      //   key="actionGroup"
      //   onSelect={() => action?.reload()}
      //   menus={[
      //     {key: 'copy', name: '复制'},
      //     {key: 'delete', name: '删除'},
      //   ]}
      // />,
    ],
  },
];
  return (
    <div>
      <PageContainer
        header={{
          title: '组合数据',
          breadcrumb: {},
        }}
      >
        <ProTable
          columns={columns}

          request={async (params = {}, sort, filter) => {
            return getGoodsLists({...sort, ...filter, ...params, ...search});
          }}
          editable={{
            type: 'multiple',
          }}
          rowKey="id"
          search={{
            labelWidth: 'auto',
            value:'hls',
          }}
          pagination={{
            pageSize: 10,
          }}
          dateFormatter="string"
          headerTitle={
            <Button key="button" icon={<PlusOutlined/>} type="primary"
                    onClick={() => history.push('/manageGoods/addGoods')}>
              添加数据组
            </Button>
          }
          // toolBarRender={() => [
          //
          // ]}
        />
      </PageContainer>
    </div>
  );
}


export default CombinedData;
